home *** CD-ROM | disk | FTP | other *** search
- package com.commerceone.util.debug;
-
- import com.commerceone.util.contract.Contract;
- import java.io.PrintWriter;
- import java.io.StringWriter;
- import java.util.StringTokenizer;
-
- public class StackTrace {
- private int stackLevels;
- private int skipDepth;
- private int savedLines;
- // $FF: renamed from: sw java.io.StringWriter
- private StringWriter field_0;
- private StringTokenizer strTok;
- // $FF: renamed from: t java.lang.Throwable
- private Throwable field_1;
- private String fileName;
- private String myName;
- private String tmpStr;
- private String className;
- private String kitchenSink;
- private String methodName;
- private String fullClassName;
- private StringBuffer stackTrace;
- private int lineNum;
-
- public String getClassName() {
- return this.className;
- }
-
- public String getMethodName() {
- return this.methodName;
- }
-
- public int getLineNum() {
- return this.lineNum;
- }
-
- public String toString() {
- return this.stackTrace.toString();
- }
-
- public StackTrace() {
- this(1, 0);
- }
-
- public StackTrace(int stackLevels) {
- this(stackLevels, 0);
- }
-
- public StackTrace(int stackLevels, int skipDepth) {
- this.stackLevels = 1;
- this.skipDepth = 0;
- this.savedLines = 0;
- this.field_0 = null;
- this.strTok = null;
- this.field_1 = null;
- this.fileName = null;
- this.myName = this.getClass().getName();
- this.tmpStr = null;
- this.className = null;
- this.kitchenSink = null;
- this.methodName = null;
- this.fullClassName = null;
- this.stackTrace = null;
- this.lineNum = -1;
- Contract.require(stackLevels > 0);
- Contract.require(skipDepth >= 0);
- this.stackLevels = stackLevels;
- this.skipDepth = skipDepth;
- this.field_0 = new StringWriter();
- this.field_1 = new Throwable();
- this.field_1.printStackTrace(new PrintWriter(this.field_0));
- this.stackTrace = new StringBuffer();
- this.strTok = new StringTokenizer(this.field_0.toString(), "\n\r");
-
- try {
- if (this.strTok.hasMoreTokens()) {
- this.strTok.nextToken();
- }
-
- while(this.strTok.hasMoreTokens()) {
- this.tmpStr = this.strTok.nextToken().replace('/', '.');
- if (this.tmpStr.indexOf(this.myName, 0) == -1) {
- if (skipDepth <= 0) {
- break;
- }
-
- --skipDepth;
- }
- }
-
- while(this.savedLines < stackLevels) {
- this.stackTrace.append(this.tmpStr.trim());
- this.stackTrace.append("\n");
- ++this.savedLines;
- if (!this.strTok.hasMoreTokens()) {
- break;
- }
-
- this.tmpStr = this.strTok.nextToken();
- }
-
- this.strTok = new StringTokenizer(this.stackTrace.toString(), " ():");
- this.strTok.nextToken();
- this.kitchenSink = this.strTok.nextToken();
- this.fileName = this.strTok.nextToken();
- this.tmpStr = this.strTok.nextToken();
- this.lineNum = Integer.parseInt(this.tmpStr);
- this.className = this.fileName.substring(0, this.fileName.indexOf(".java")) + ".class";
- this.methodName = this.kitchenSink.substring(this.kitchenSink.lastIndexOf(".") + 1);
- this.fullClassName = this.kitchenSink.substring(0, this.kitchenSink.lastIndexOf(".")) + ".class";
- } catch (Exception e) {
- System.err.println("Exception: " + ((Throwable)e).getMessage());
- }
-
- }
-
- public String getFullClassName() {
- return this.fullClassName;
- }
-
- public String getFileAndLineNum() {
- return this.fileName + ":" + this.lineNum;
- }
-
- public String getFileName() {
- return this.fileName;
- }
- }
-